package concurrency;

/**
 * 编码的变体
 *
 * 2018年 09月 24日 星期一
 * @author fireway
 */
public class SimpleThread extends Thread {
    private int mCountDown = 5;

    private static int sCount = 0;

    public SimpleThread() {
        super(Integer.toString(++sCount));
        start();
    }

    @Override
    public String toString() {
        String s = "#" + getName() + "(" + mCountDown + "), ";
        return s;
    }

    @Override
    public void run() {
        while(true) {
            System.out.print(this);
            if (0 == --mCountDown) {
                return;
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            new SimpleThread();
        }
    }
}
